﻿<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>商务结算管理</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<!--标准mui.css-->
		<link rel="stylesheet" href="../css/mui.min.css">
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../css/base2.css" />
		<link rel="stylesheet" type="text/css" href="../css/Monitor.css" />
		<link rel="stylesheet" type="text/css" href="../css/app.css" />
	</head>

	<body>

		<div class="mui-input-row mui-search">
			<input type="search" id="searchInput" onkeyup="enterSearch(event)" class="mui-input-clear" placeholder="输入查询条件">
			<input id="value" hidden="true" />
			<input id="proid" hidden="true" />
		</div>
		<div class="list-t-wrap">
			<div id="pullrefresh" class="mui-scroll-wrapper">
				<div class="mui-scroll" id="mui-table-view">
					<!--
                    	作者：cumtwf@126.com
                    	时间：2016-10-15
                    	描述：放内容
                    -->
				</div>
			</div>

	</body>
	<script src="../js/mui.min.js"></script>
	<script src="../js/wf.js"></script>
	<script src="../js/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/tools/template.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		mui.init({
			gestureConfig: {
				longtap: true
			},
			pullRefresh: {
				container: '#pullrefresh',
				down: {
					callback: pulldownRefresh
				},
				up: {
					contentrefresh: '正在加载...',
					callback: pullupRefresh
				}
			}

		});
		var pagesize = 8;
		var page = 1;
		var TotalPage = 1;
		var strWhere = "";
		mui.plusReady(function() {
			var self = plus.webview.currentWebview();
			var username = self.username;
			var userid = self.userid;
			var proid = self.proid;
			document.getElementById("value").value = self.value;
			document.getElementById("proid").value = self.proid;
			//document.getElementById("username").value=username;
			//----------------单击事件------------------
			mui("#mui-table-view").on("tap", ".content_box", function() {
				var id = this.getAttribute("id");
				mui.openWindow({
					url: 'businessupdatedetail.html',
					id: 'businessupdatedetail',
					extras: {
						proid: proid,
						username: username,
						bid: id,
						value: self.value
					}
				});
			})
		});

		/**
		 * 下拉刷新具体业务实现
		 */
		function pulldownRefresh() {
			setTimeout(function() {
				pagesize = 8;
				page = 1;
				TotalPage = 1;
				//			var table = document.body.querySelector('.mui-table-view');
				//			table.innerHTML="";
				$("#mui-table-view").empty();
				mui('#pullrefresh').pullRefresh().endPullupToRefresh((page > TotalPage));
				loaddata(strWhere, page++, pagesize);
				mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
			}, 1500);
		}
		/**
		 * 上拉加载具体业务实现
		 */
		function pullupRefresh() {
			setTimeout(function() {
				mui('#pullrefresh').pullRefresh().endPullupToRefresh((page > TotalPage)); //参数为true代表没有更多数据了。
				// 加载更多的内容到列表中
				if(page <= TotalPage) {
					loaddata(strWhere, page++, pagesize);
				}
			}, 1500);
		}
		if(mui.os.plus) {
			mui.plusReady(function() {
				setTimeout(function() {
					mui('#pullrefresh').pullRefresh().pullupLoading();
				}, 1000);

			});
		} else {
			mui.ready(function() {
				mui('#pullrefresh').pullRefresh().pullupLoading();
			});
		}

		function loaddata(strWhere, page, pagesize) {
			strWhere = "PID=" + document.getElementById("proid").value;
			var value = document.getElementById("value").value;
			plus.nativeUI.showWaiting();
			wf.ajax("Business/BusinessList", {
				traditional: true,
				type: "get",
				data: {
					"value": value,
					"strWhere": strWhere,
					"page": page,
					"pagesize": pagesize,
					"orderby": "BID"
				}, //
				dataType: "json",
				success: function(resule) {
					plus.nativeUI.closeWaiting();
					if(resule.Code == "20000") {
						var obj = JSON.parse(resule.Data);
						var data = {
							data: obj.DataList,
							url: wf.server_Domain
						};
						$("#mui-table-view").append(template('tempList', data));
//						var table = document.body.querySelector('.mui-table-view');
//						for(var i = 0; i < obj.DataList.length; i++) {
//							var li = document.createElement('li');
//							li.className = 'mui-table-view-cell';
//							var item = obj.DataList[i];
//							var LaborAccount = item.LaborAccount;
//							var PreIncome = item.PreIncome;
//							var RealPro = item.RealPro;
//							li.id = item.BID; //获取ID	
//							var auditinfo = 0;
//							if(item.AuditStatus == 0) {
//								auditinfo = "待审核";
//							} else if(item.AuditStatus == 2) {
//								auditinfo = "已审核通过";
//							} else if(item.AuditStatus == 3) {
//								auditinfo = "审核不通过";
//							}
//
//							li.innerHTML = "<div  class=\"mui-table\"><div class=\"mui-table-cell mui-col-xs-10\"><h4 class=\"mui-ellipsis\">" + "劳务结算：" + item.LaborAccount + "</h4><img class=\"mui-media-object mui-pull-left\" src=\"../images/cbd.jpg\"><h5>" + "预计收入:" + item.PreIncome + "</h5><h5>" + "实际产值:" + item.RealPro + "</h5><p class=\"mui-h6 mui-ellipsis\">审核状态：" + auditinfo + "</p></div><div class=\"mui-table-cell mui-col-xs-2 mui-text-right\"><span class=\"mui-h5\">" + item.CreatePeople + "</span></div></div>";
//							table.appendChild(li);
//						}
					} else {
						plus.nativeUI.closeWaiting();
						mui.toast(resule.Msg);
					}
				}
			});
		}

		function enterSearch(e) {
			if(e.keyCode == 13) {
				document.body.querySelector('#searchInput').blur();
				setTimeout(function() {
					var inputstr = document.body.querySelector('#searchInput').value;
					pagesize = 8;
					page = 1;
					TotalPage = 1;
					strWhere = "LaborAccount like '%" + inputstr + "%'";
					var table = document.body.querySelector('.mui-table-view');
					table.innerHTML = "";
					//mui('#pullrefresh').pullRefresh().endPullupToRefresh((page>TotalPage));
					loaddata(strWhere, page++, pagesize);
					//mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
				}, 1500);
			}
		}
	</script>
<script id="tempList" type="text/html">
		<%for(var i=0;i<data.length;i++){%>
		<div class="content_box" id="<%=data[i].BID%>">
			<img class="image Head_portrait" src="<%=url%>FileUpload/ReadPic?name=User_<%=data[i].CreatePeople%>" " />
			<p>
				<span class="xinghao ">
						劳务结算：<%=data[i].LaborAccount%></span><br/>
				<span class="date "> 预计收入:
								<%if(data[i].PreIncome!= " "){%>
									<%=data[i].PreIncome%>
								<%}else{%>
									暂无信息
								<%}%>
							</span><br/>
							<span class="date "> 实际产值:
								<%if(data[i].RealPro!= " "){%>
									<%=data[i].RealPro%>
								<%}else{%>
									暂无信息
								<%}%>
							</span><br/>
				<span class="date "> 审核状态：
								<%if(data[i].AuditStatus==0){%>
									待审核
								<%}else if(data[i].AuditStatus==2){%>
									已审核通过
								<%}else if(data[i].AuditStatus==3){%>
									审核不通过
								<%}%>
								
							</span><br/>
				<span class="gongzuo ">创建人：
								<%if(data[i].CreatePeople != " "){%>
									<%=data[i].CreatePeople%>
								<%}else{%>
									暂无信息
								<%}%>
							</span>
			</p>
			
		</div>
		<div class="clear "></div>
		<div class="Division "></div>
		<%}%>

	</script>
</html>